<!--大额即时转账业务回执录入  页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      defaultEventKey="entryTable"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
      :labelWidth="80"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      defaultEventKey="entryTable"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('details', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细页面弹出框 -->
    <edit-info-dialog
      ref="editInfoDialog"
      :dictMap="dictMap"
      :formData="formData"
      @editComplete="editComplete"
    ></edit-info-dialog>
  </div>
</template>
<script>
import { apiUrlConfig, detail } from "@/api/cnaps/baseBiz/send/hvps/hvps142.js";
import { listPageMixin } from "@/libs/listPageMixin";
import EditInfoDialog from "./components/EditInfo";
import AmountRangeSearch from "@/views/components/AmountSearchInput";

export default {
  name: "HvpsDelayedSettleReceiptEntry",
  mixins: [listPageMixin],
  components: { EditInfoDialog, AmountRangeSearch },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: [
        "PKG_TYPE",
        "BIZ_TYPE",
        "PKG_STATUS",
        "BANK_BIZ_TYPE",
        "BIZ_CTGY_HVPS_115",
        "DRCTCODE",
        "CREDITDEBITCODE",
        "Cnaps2Dict.CP2_BRNO",
        "PROCESSSTATUS",
        "CURCD_5701",
        "REFUNDTYPECODE",
        "BIZRT_STATUS",
      ],
      //  明细弹框数据
      // form表单字段
      formData: {},
      showSearch: true,
      // 查询参数
      queryParams: {
        id: "",
        brno: "",
        cpgdate: "",
        cpgdate2: "",
        workdate: "",
        workdate2: "",
        amount1: "",
        amount2: "",
      },
      formOptions: [],
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        { label: `内部机构号`, prop: "brno", width: "170", sortable: false },
        {
          label: `系统编号`,
          prop: "sysCode",
          width: "180",
          dictCode: "SYSTEMCODE",
          sortable: false,
        },
        { label: `交易流水号`, prop: "id", width: "170", sortable: false },
        {
          label: `CPG日期`,
          prop: "cpgdate",
          width: "160",
          sortable: false,
          type: "date",
        },
        {
          label: `工作日期`,
          prop: "workdate",
          width: "160",
          sortable: false,
          type: "date",
        },
        {
          label: `报文类型`,
          prop: "pkgNo",
          width: "180",
          dictCode: "PKG_TYPE",
          sortable: false,
        },
        {
          label: `业务类型`,
          prop: "bizTypeCode",
          width: "180",
          dictCode: "BIZ_TYPE",
          sortable: false,
        },
        {
          label: `业务种类`,
          prop: "bizCtgyCodeDesc",
          width: "180",
          sortable: false,
        },
        {
          label: `借贷标识`,
          prop: "cdIndicator",
          width: "180",
          dictCode: "CREDITDEBITCODE",
          sortable: false,
        },
        {
          label: `特许参与者`,
          prop: "espOrg",
          width: "160",
          sortable: false,
        },
        {
          label: `交易金额`,
          prop: "amount",
          width: "180",
          sortable: false,
          type: "price",
        },
        {
          label: `业务状态`,
          prop: "txnStatus",
          width: "180",
          dictCode: "TXN_STATUS",
          sortable: false,
        },
        {
          label: `通讯状态`,
          prop: "status",
          width: "180",
          dictCode: "PKG_STATUS",
          sortable: false,
        },
      ],
    };
  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "input",
        prop: "brno",
        defaultAttr: {
          label: "内部机构号",
          placeholder: "请输入内部机构号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "details":
          // 明细页面
          detail({ id: row.id }).then((res) => {
            this.formData = res.result;
            this.$refs.editInfoDialog.show();
          });

          break;
      }
    },
  },
};
</script>
